﻿using RTW.Core.Ioc;
using RTW.Core.Repository;
using RTW.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace RTW.Servers
{
    public class TFilesApplyServer:BaseServers<TFilesApply>,IAutoInject
    {
        private readonly IRepositoryAsync<TFilesApply> repositoryAsync;
        public TFilesApplyServer()
        {
            repositoryAsync = new DapperAsyncRepository<TFilesApply>();
        }

        /// <summary>
        /// 获取集合数据
        /// </summary>
        /// <returns></returns>
        public async Task<List<TFilesApply>> GetAllApply()
        {
            return (await repositoryAsync.GetAllEnumerableAsync()).ToList();
        }
        /// <summary>
        /// 根据状态获取数据
        /// </summary>
        /// <returns></returns>
        public async Task<List<TFilesApply>> GetAllApplyWhere(int? state)
        {
            string sql = "select * from TFilesApply ";
            if (state != -1)
                sql += "where state=" + state;
            return (await repositoryAsync.SqlWithParams(sql)).ToList();
        }
    }
}
